import { defineStore } from 'pinia'
import { SideBarType } from '@/types'
import { updateCSLocation } from '@/utils/cs.ts'

export const useLayoutStore = defineStore('layout', {
	state: () => ({
		menu: '',
		menuType: '',
		menuOpen: true,
		menuGroupOpen: '',
		sidebar: '' as SideBarType
	}),
	actions: {
		setMenu(val: string) {
			this.menu = val
		},
		setMenuType(val: string) {
			this.menuType = val
		},
		setMenuOpen(val: boolean) {
			this.menuOpen = val
		},
		setMenuGroupOpen(val: string) {
			this.menuGroupOpen = val
		},
		setSidebar(val: SideBarType) {
			this.sidebar = val
			updateCSLocation(!!val)
		}
	},
	getters: {},
	persist: true
})
